<?php

class GPCSFilter
{
    public function __construct()
    {
        if(!self::filter())
        {
            die("GPCSFilter::__construct() Failure!");
        }
    }

    public static function filter()
    {
        if(isset($_GET))     $fget     = self::filterGet();
        if(isset($_POST))    $fpost    = self::filterPost();
        if(isset($_COOKIE))  $fcookie  = self::filterCookie();
        if(isset($_SESSION)) $fsession = self::filterSession();
        var_dump($_SESSION);
        if($fget && $fpost || $fcookie || $fsession) 
        {
            return true;
        }
        else return false;
    }
    public static function filterGet()
    {
        $_GET = array_map("addslashes", $_GET);
        $_GET = array_map("htmlspecialchars", $_GET);
        return true;
    }

    public static function filterPost()
    {
        $_POST = array_map("addslashes", $_POST);
        $_POST = array_map("htmlspecialchars", $_POST);
        return true;
    }

    public static function filterCookie()
    {
        $_COOKIE = array_map("addslashes", $_COOKIE);
        $_COOKIE = array_map("htmlspecialchars", $_COOKIE);
        return true;
    }

    public static function filterSession()
    {
        $_SESSION = array_map("addslashes", $_SESSION);
        $_SESSION = array_map("htmlspecialchars", $_SESSION);
        return true;
    }

    public function __destruct()
    {
        self::filter();
    }
}

var_dump(GPCSFilter::filter());

?>